package com.idrem.views.home;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.idrem.R;
import com.idrem.views.bf.BaiduMapActivity;
import com.idrem.views.bf.BfglActivity;
import com.idrem.views.erwei.CaptureActivity;

public class HomeActivity extends Activity {
	private static String TAG = "HomeActivity";

	private GridView gridView;

	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		setContentView(R.layout.activity_home);
		
		gridView = (GridView) findViewById(R.id.home_gridview);

		ArrayList<HashMap<String, Object>> lst = new ArrayList<HashMap<String, Object>>();
		for (int i = 0; i < 9; i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			
			switch (i) {
			case 0:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "拜访管理");
			break;
			case 1:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "二维扫描");
				break;
			case 2:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "库存管理");
				break;
			case 3:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "门店管理");
				break;
			case 4:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "商品资料");
				break;
			case 5:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "绩效报表");
				break;
			case 6:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "信息互通");
				break;
			case 7:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "数据同步");
				break;
			case 8:
				map.put("itemImage", R.drawable.ic_launcher);
				map.put("itemText", "更多功能");
				break;
			};
			

			lst.add(map);
		}

		SimpleAdapter adpter = new SimpleAdapter(this, lst, R.layout.home_item,
				new String[] { "itemImage", "itemText" }, new int[] {
						R.id.imageView_ItemImage, R.id.textView_ItemText });

		gridView.setAdapter(adpter);

		gridView.setOnItemClickListener(new gridView1OnClickListener());
	}

	class gridView1OnClickListener implements OnItemClickListener {

		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			switch (arg2) {
			case 0:
				startActivity(new Intent(HomeActivity.this, BfglActivity.class));
				break;
			case 1:
				startActivity(new Intent(HomeActivity.this, CaptureActivity.class));
				break;
			case 2:
				
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			case 6:
				break;
			case 7:
				break;
			case 8:
				startActivity(new Intent(HomeActivity.this, BaiduMapActivity.class));
				break;

			default:
				break;
			}
		}
	}

}
